﻿using Inovout.Organizations.Models;
using Inovout.People.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Inovout.Kuajing.Store.Web.Controllers
{
    public class EmployeeController : KJBaseController<Employee>
    {
        
        public EmployeeController() 
        {

        }
        public void  Create(string personName,string personEmail,string persionTel)
        {
            Person person = new Person();
            person.Email = personEmail;
            person.Name = personName;
            Phone phone = new Phone();
            phone.Value = persionTel;
            phone.Label = PhoneLabel.Mobile;
            person.Phones.Add(phone);

            Employee employee = new Employee();
            employee.Person = person;
            

            //    IEnumerable<Phone> telphones = employee.Person.Phones.AsQueryable<Phone>().Where<Phone>(model => model.Label == PhoneLabel.Tel);
            //    if (telphones != null && telphones.Count() != 0)
            //    {
            //        tel = telphones.First();
            //    }
            //    else
            //    {
            //        tel = new Phone() { Label = PhoneLabel.Tel };
            //    }
            //}
            //else
            //{
            //    person = new Person();
            //    employee = new Employee();
            //    employee.Person = person;
            //    phone = new Phone() { Label = PhoneLabel.Mobile };
            //    tel = new Phone() { Label = PhoneLabel.Tel };
            //}
            //employee.Person.Name = exporterInfo.OrderPersonName.Trim();
            //phone.Value = exporterInfo.Phone.Trim();
            //if (!string.IsNullOrEmpty(exporterInfo.TelPhone))
            //{
            //    tel.Value = exporterInfo.TelPhone.Trim();
            //    tel.Person = employee.Person;
            //    employee.Person.Phones.Add(tel);
            //}
            //phone.Person = employee.Person;
            //employee.Person.Phones.Add(phone);

            //employee.Organization = organizationUnit;
            //employeeService.Save(employee);

        }
	}
}